﻿using Sasa.QualityTools.CodeAnalysis.Core.Requests;
using System;
using System.Collections.Generic;
using System.IO;

namespace Sasa.QualityTools.CodeAnalysis.Core.Services.CodeAnalysis
{
    internal class FxCopProjectAnalyzer : CodeAnalyzerBase
    {
        private FxCopProjectAnalysisRequest request;

        private FxCopReportValueConverter converter;


        protected internal override IFxCopReportValueConverter FxCopReportValueConverter
        {
            get
            {
                return converter;
            }
        }


        internal FxCopProjectAnalyzer(FxCopProjectAnalysisRequest request)
            : base(request)
        {
            this.request = request;
            converter = new FxCopReportValueConverter();
            converter.FxCopProjectPath = request.FxCopProjectPath;
        }


        protected internal override IEnumerable<string> CreateFxCopCmdOptions()
        {
            if (!File.Exists(request.FxCopProjectPath)) throw new InvalidOperationException("The specified FxCop project (" + request.Target + ") doesn't exist.");

            var options = new List<string>();
            options.Add("/p:" + '"' + request.FxCopProjectPath + '"');
            options.Add("/o:" + '"' + OutputPath + '"');
            return options;
        }
    }
}
